<template>
	<view class="page_view">
		<view class="zhanwei"></view>
		<view class="page_view_item" @click="go_edituserinfo">
			<view class="page_view_item_left">
				个人信息
			</view>
			<u-icon name="arrow-right" color="#333333" size="14"></u-icon>
		</view>
		<view class="page_view_item" @click="xieyi(2)">
			<view class="page_view_item_left">
				隐私政策
			</view>
			<u-icon name="arrow-right" color="#333333" size="14"></u-icon>
		</view>
		<view class="page_view_item" @click="xieyi(1)">
			<view class="page_view_item_left">
				用户协议
			</view>
			<u-icon name="arrow-right" color="#333333" size="14"></u-icon>
		</view>
		<view v-if="token" @click="unregister" class="page_view_item1">
			注销账号
		</view>
	</view>
</template>

<script>
	import {
		log_off
	} from "@/api/common.js"
	export default {
		data() {
			return {
				yinsizhengce: {},
				fuwuxieyi: {},
				nowVersion: '',
				newVersion: {},
				downUrl: '',
				needUpdate: false,
				token:uni.getStorageSync('token')
			}
		},
		onLoad() {
			
		},
		computed: {
			
		},
		onBackPress() {
			
		},
		methods: {
			is_login(){
				let token = uni.getStorageSync('token')
				if(!token){
					uni.showToast({
						title:'请先登录',
						icon:'none'
					})
					setTimeout(()=>{
						uni.navigateTo({
							url:'/pages/ChooseName/ChooseName'
						})
					},1500)
					return false
				}else{
					return true
				}
			},
			xieyi(type){
				uni.navigateTo({
					url:'/pages/xieyi/xieyi?type='+type
				})
			},
			// 注销
			unregister(){
				uni.showModal({
					title:'提示',
					content:'确认注销当前账号吗？',
					success:res=>{
						if(res.confirm){
							log_off().then(res=>{
								uni.showToast({
									title:'注销成功',
									icon:'none',
								})
								uni.clearStorageSync();
								setTimeout(()=>{
									uni.navigateBack({
										delta:1
									})
								},800)
							})
						}
					}
				})
			},
			go_edituserinfo() {
				if(this.is_login()){
					uni.navigateTo({
						url: '/pages/EditUserInfo/EditUserInfo'
					})
				}
			},
		}
	}
</script>

<style>
	.btn {
		width: 500rpx;
		height: 110rpx;
		border-radius: 28rpx;
		background: #ccc;
		color: #fff;
		margin: 30rpx auto;
		font-size: 30rpx;
		font-weight: 700;
		text-align: center;
		line-height: 110rpx;
	}
	page {
		background-color: #F4F4F8;
	}

	.page_view {
		width: 100%;
	}

	.zhanwei {
		width: 100%;
		height: 22rpx;
	}

	.page_view_item {
		width: 100%;
		height: 104rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		background-color: #fff;
		padding: 0 30rpx;
		box-sizing: border-box;
		border-bottom: 1rpx solid #F4F4F4;
	}

	.page_view_item_right {
		color: #CCC;
		text-align: right;
		font-family: Source Han Sans SC;
		font-size: 26rpx;
		font-weight: 400;
	}

	.ma20 {
		margin-top: 20rpx;
	}

	.page_view_item1 {
		position: fixed;
		bottom: 100rpx;
		left: 0;
		right: 0;
		text-align: center;
		color: #999;
		text-align: center;
		font-family: Alibaba PuHuiTi 2.0;
		font-size: 28rpx;
		font-weight: 400;
	}
</style>